/*     */ package com.zimbra.cs.mailbox.calendar;
/*     */ 
/*     */ import com.zimbra.common.calendar.ICalTimeZone.SimpleOnset;
/*     */ import java.util.Calendar;
/*     */ import java.util.GregorianCalendar;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class WindowsSystemTime
/*     */ {
/*     */   private int mYear;
/*     */   private int mMonth;
/*     */   private int mDayOfWeek;
/*     */   private int mDay;
/*     */   private int mHour;
/*     */   private int mMinute;
/*     */   private int mSecond;
/*     */   private int mMilliseconds;
/*     */   
/*     */   public WindowsSystemTime(int year, int month, int dayOfWeek, int day, int hour, int minute, int second, int milliseconds)
/*     */   {
/*  44 */     this.mYear = year;
/*  45 */     this.mMonth = month;
/*  46 */     this.mDayOfWeek = dayOfWeek;
/*  47 */     this.mDay = day;
/*  48 */     this.mHour = hour;
/*  49 */     this.mMinute = minute;
/*  50 */     this.mSecond = second;
/*  51 */     this.mMilliseconds = milliseconds;
/*     */     
/*  53 */     if (this.mYear == 0)
/*     */     {
/*  55 */       if ((this.mDayOfWeek < 0) || (this.mDayOfWeek > 6)) {
/*  56 */         throw new IllegalArgumentException("DayOfWeek field must be in [0, 6] range");
/*     */       }
/*  58 */       if ((this.mDay < 0) || (this.mDay > 5)) {
/*  59 */         throw new IllegalArgumentException("Day field specifying week number must be in [1, 5] range");
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*  64 */   public int getYear() { return this.mYear; }
/*  65 */   public int getMonth() { return this.mMonth; }
/*  66 */   public int getDayOfWeek() { return this.mDayOfWeek; }
/*  67 */   public int getDay() { return this.mDay; }
/*  68 */   public int getHour() { return this.mHour; }
/*  69 */   public int getMinute() { return this.mMinute; }
/*  70 */   public int getSecond() { return this.mSecond; }
/*  71 */   public int getMilliseconds() { return this.mMilliseconds; }
/*     */   
/*     */   public String toString() {
/*  74 */     StringBuffer sb = new StringBuffer(200);
/*  75 */     sb.append("SYSTEMTIME {\n");
/*  76 */     sb.append("    wYear         = ").append(this.mYear).append("\n");
/*  77 */     sb.append("    wMonth        = ").append(this.mMonth).append("\n");
/*  78 */     sb.append("    wDayOfWeek    = ").append(this.mDayOfWeek).append("\n");
/*  79 */     sb.append("    wDay          = ").append(this.mDay).append("\n");
/*  80 */     sb.append("    wHour         = ").append(this.mHour).append("\n");
/*  81 */     sb.append("    wMinute       = ").append(this.mMinute).append("\n");
/*  82 */     sb.append("    wSecond       = ").append(this.mSecond).append("\n");
/*  83 */     sb.append("    wMilliseconds = ").append(this.mMilliseconds).append("\n");
/*  84 */     sb.append("}");
/*  85 */     return sb.toString();
/*     */   }
/*     */   
/*     */   public ICalTimeZone.SimpleOnset toSimpleOnset() {
/*  89 */     if (this.mYear != 0) return null;
/*  90 */     int week = this.mDay;
/*  91 */     if (week == 5)
/*  92 */       week = -1;
/*  93 */     return new ICalTimeZone.SimpleOnset(week, this.mDayOfWeek + 1, this.mMonth, this.mDay, this.mHour, this.mMinute, this.mSecond);
/*     */   }
/*     */   
/*     */   public static WindowsSystemTime fromSimpleOnset(ICalTimeZone.SimpleOnset onset)
/*     */   {
/*  98 */     if (onset == null) return null;
/*  99 */     int week = onset.getWeek();
/* 100 */     if (week == -1)
/* 101 */       week = 5;
/* 102 */     if (week != 0) {
/* 103 */       return new WindowsSystemTime(0, onset.getMonth(), onset.getDayOfWeek() - 1, week, onset.getHour(), onset.getMinute(), onset.getSecond(), 0);
/*     */     }
/*     */     
/*     */ 
/* 107 */     Calendar cal = new GregorianCalendar();
/* 108 */     int year = cal.get(1);
/* 109 */     cal.set(year, onset.getMonth() - 1, onset.getDayOfMonth(), onset.getHour(), onset.getMinute());
/* 110 */     return new WindowsSystemTime(year, onset.getMonth(), cal.get(7) - 1, onset.getDayOfMonth(), onset.getHour(), onset.getMinute(), onset.getSecond(), 0);
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/mailbox/calendar/WindowsSystemTime.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */